package cheme.Interpreter.AST;

import java.util.ArrayList;
import java.util.List;

import cheme.Interpreter.AST.Interfaces.IAstChemicalProcess;
import cheme.Interpreter.AST.Interfaces.IAstEquation;
import cheme.Interpreter.AST.Interfaces.IAstNode;
import cheme.Interpreter.AST.Interfaces.IAstVariableDeclaration;


public class AstChemicalProcess implements IAstChemicalProcess
{
	List<IAstVariableDeclaration> declarations = new ArrayList<IAstVariableDeclaration>();
	List<IAstEquation> equations = new ArrayList<IAstEquation>();
	
	public AstChemicalProcess()
	{
	}
	
	public void add(IAstNode node)
	{
		if(node instanceof IAstVariableDeclaration)
		{
			add((IAstVariableDeclaration)node);
		}
		else if(node instanceof IAstEquation)
		{
			add((IAstEquation)node);
		}
	}
	
	public void add(IAstVariableDeclaration decl)
	{
		declarations.add(decl);
	}
	
	public void add(IAstEquation eq)
	{
		equations.add(eq);
	}
	
	@Override
	public String toString()
	{
		String string = "";
		
		for(IAstVariableDeclaration decl : declarations)
		{
			string += decl.toString() + "\n";
		}
		
		for(IAstEquation eq : equations)
		{
			string += eq.toString() + "\n";
		}
		
		return string;
	}
}
